require(['./config'], () => {
    require(['swiper', 'template','url','header','footer'], (Swiper,template,url) => {
      
        class Index {
            constructor() {
                this.swiper()
                this.getCategory()
                this.getBrand  () 
            }
            swiper() {
                var mySwiper = new Swiper('.swiper-container', {
                    // direction: 'vertical', // 垂直切换选项
                    loop: true, // 循环模式选项

                    // 如果需要分页器
                    pagination: {
                        el: '.swiper-pagination',
                    },

                    // 如果需要前进后退按钮
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    },
                    scrollbar: {
                        el: '.swiper-scrollbar',
                      },
                      autoplay: {
                        delay: 3000,
                        stopOnLastSlide: false,
                        disableOnInteraction: false
                      },
                   
                })

            }

            // json渲染
            getCategory () {
                $.get('/libs/json/homeCategory.json', resp => {
                    // console.log(resp)
                    
                    const str = template('art',{
                        list: resp
                    })
                    // console.log(str)
                    $('#ulks').html(str)
                })
            }

             // rap2渲染
            getBrand () {
                $.get(`${url.baseUrl}/brand`,resp => {
                    if(resp.code === 200){
                        // console.log(resp)
                        const {list} = resp.body
                        $('#mxcpInfoList').html(template('mxcpTemplate',{list}))
                    }
                })
            }
        }
        new Index()
    })
})